﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data.OleDb;

namespace WebSite_CodeMan.BLL
{
    public class LinkInfo
    {
        /// <summary>
        /// 获取所有的链接信息
        /// </summary>
        /// <returns></returns>
        public static OleDbDataReader GetLinkMes(string strLID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT * FROM T_Link_Info WHERE 1=1 {0}", (string.IsNullOrEmpty(strLID)) ? "" : " AND T_LinkID=" + strLID), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 编辑链接数据
        /// </summary>
        /// <param name="ClassID"></param>
        /// <param name="strClassName"></param>
        /// <param name="strKey"></param>
        /// <param name="strDes"></param>
        /// <returns></returns>
        public static bool EditLinkMes(string strClassName, string strKey, string strDes,string strLID)
        {
            try
            {
                string strSql = " INSERT INTO  T_Link_Info (T_LinkTitle,T_LinkImage,T_LinkUrl) VALUES (@T_LinkTitle,@T_LinkImage,@T_LinkUrl) ";
                if (!string.IsNullOrEmpty(strLID))
                {
                    strSql = " UPDATE T_Link_Info SET T_LinkTitle=@T_LinkTitle,T_LinkImage=@T_LinkImage,T_LinkUrl=@T_LinkUrl WHERE T_LinkID=@T_LinkID ";
                }
                OleDbParameter[] parm = { new OleDbParameter("@T_LinkTitle", strClassName),
                                          new OleDbParameter("@T_LinkImage", strKey),
                                          new OleDbParameter("@T_LinkUrl", strDes),
                                          new OleDbParameter("@T_LinkID", strLID)};
                return (DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, strSql, parm) > 0) ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 删除类别信息
        /// </summary>
        /// <param name="strClassID"></param>
        /// <returns></returns>
        public static bool DelLinkMes(string strClassID)
        {
            try
            {
                OleDbParameter[] parm = { new OleDbParameter("@T_LinkID", strClassID) };
                return (DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, " DELETE FROM T_Link_Info WHERE T_LinkID=@T_LinkID ", parm) > 0) ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        } 
    }
}
